#pragma once
#include "loki/Singleton.h"
#include "loki/SmartPtr.h"

typedef std::tr1::shared_ptr<account_item> accountItem;
typedef map<string,accountItem> mapAccount;
typedef theadmap<string,accountItem> safemapAccount;

typedef threadlock::autoguard<safemapAccount::maplockpolicy> safemapAccountLock;
void save_to_file(LPSTR filename, LPVOID lpData, int nSize);
class CAccountService
{

protected:
	safemapAccount m_futureAccount;
	safemapAccount m_stockAccount;
	

public:
	CAccountService(void);
	~CAccountService(void);


	bool GetAccount( const string& key, accountType acctype, account_item& accountItemVar );
	bool SetAccount( const string& key, accountType acctype, const account_item& accountItemVar );
protected:
	bool GetAccount( const string& key, safemapAccount& accountMap, account_item& accountItemVar );
	bool SetAccount( const string& key, safemapAccount& accountMap, const account_item& accountItemVar );
	bool SaveAccount(const string& strtype, const string& key, safemapAccount& accountMap );
	BOOL LoadFromFile(TCHAR* lpszPath, safemapAccount& accountMap);

public:
	bool SaveAccount( const string& key, accountType acctype );
	BOOL LoadFromFile();
	
	
};


typedef Loki::SingletonHolder<CAccountService>  AccountServiceHoder;
